package com.zxc.user.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AdAuthDto;
import com.zxc.user.service.ApUserRealnameService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.heima.common.constants.UserConstants.FAIL_AUTH;
import static com.heima.common.constants.UserConstants.PASS_AUTH;

@RestController
@RequestMapping("/api/v1/auth")
public class ApUserAuthController {
    @Resource
    private ApUserRealnameService apUserRealnameService;

    @PostMapping("/list")
    public ResponseResult findUserList(@RequestBody @Valid AdAuthDto dto) {
        return apUserRealnameService.findUserList(dto);
    }

    @PostMapping("/authPass")
    public ResponseResult authPass(@RequestBody AdAuthDto dto) {
        return apUserRealnameService.updateStatus(dto, PASS_AUTH);
    }

    @PostMapping("/authFail")
    public ResponseResult authFail(@RequestBody AdAuthDto dto) {
        return apUserRealnameService.updateStatus(dto, FAIL_AUTH);
    }

    @GetMapping("/one_vo/{id}")
    public ResponseResult details(@PathVariable("id") Integer id) {

        return apUserRealnameService.details(id);
    }
}
